#ifndef _IO_
#define _IO_

namespace fileio
{
	
	inline FILE * Open(const wchar * fname, const wchar * m)
	{
#ifdef WIN32
		FILE *fp = NULL; 
		_wfopen_s(&fp, fname, m); 
		return fp;
#elif defined (__ANDROID__)
		FILE *fp = NULL;
		char f[256] = {0,};
		char t[16] = {0,};
		utf16toutf8(f, sizeof(f), fullpath.c_str());
		utf16toutf8(t, sizeof(t), m);

		fp = ::fopen(f, t);
		return fp;
#endif
	}

	inline void Close(FILE *fp)
	{
#ifdef WIN32
		fclose(fp);
#else
		fclose(fp);
#endif
	}

	inline int Size(FILE *fp)
	{
		fseek(fp, 0L, SEEK_END);
		int numbytes = ftell(fp);
		fseek(fp, 0L, SEEK_SET);
		return numbytes;
	}

	inline int Read(char *buffer, int len, FILE *fp)
	{
		return fread(buffer, 1, len, fp);
	}

	inline int remove(const wchar * fname) 
	{
#ifdef WIN32
		return ::_wremove(fname);
#elif defined (__ANDROID__)
		char f[256];
		conv_s(f, _countof(f), fname);
		return ::remove(f);
#endif
	}

	inline int access(const wchar * fname, int accmode)
	{
#ifdef WIN32
		return ::_waccess(fname, accmode);
#elif defined (__ANDROID__)
		char f[256];
		conv_s(f, _countof(f), fname);
		return ::access(f, accmode);
#endif
	}

}

#endif